using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;

namespace IQIGame.Onigao.GamePlay
{
    public class UIN_HeroSkillUnit : UIBaseNode
    {
        #region Template Generate,don't modify
        protected class UIB_UIN_HeroSkillUnit
        {
            #region ObjectBinding Generate
            public IQIGame.Onigao.Framework.ExImage icon { protected set; get; }
            public IQIGame.Onigao.Framework.ExText lv { protected set; get; }
            public UnityEngine.GameObject lockRoot { protected set; get; }
            public UnityEngine.GameObject select { protected set; get; }
            public IQIGame.Onigao.Framework.ExArtSpriteNum imageType { protected set; get; }
            public IQIGame.Onigao.Framework.ExArtSpriteNum imageSelectType { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExImage>("icon", out var __tbv0);
                icon = __tbv0;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("lv", out var __tbv1);
                lv = __tbv1;
                __binding.TryGetVariableValue<UnityEngine.GameObject>("lockRoot", out var __tbv2);
                lockRoot = __tbv2;
                __binding.TryGetVariableValue<UnityEngine.GameObject>("select", out var __tbv3);
                select = __tbv3;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExArtSpriteNum>("imageType", out var __tbv4);
                imageType = __tbv4;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExArtSpriteNum>("imageSelectType", out var __tbv5);
                imageSelectType = __tbv5;
            }
            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify

        #region fields



        #endregion fields

        #region properties

        protected UIB_UIN_HeroSkillUnit ui { get; set; }
        protected UIMsgDispatcher uiMsgDispatcher => _msgDispatcher as UIMsgDispatcher;

        #endregion properties

        protected override void BeforeInit()
        {
            ui = new UIB_UIN_HeroSkillUnit();
            ui.InitBinding(csObjBind);
        }

        protected override void OnInit()
        {

        }

        protected override void OnShow()
        {

        }

        protected override void OnHide()
        {

        }

        /// <summary>
        /// 添加UGUI侦听
        /// </summary>
        protected override void AddUGUIListener()
        {

        }

        /// <summary>
        /// 添加全局侦听（MsgDispatcher）
        /// </summary>
        protected override void AddMsgListeners()
        {

        }

        protected override void OnDispose()
        {

        }

        #region methonds

        public void Show(HeroData heroData, int skillIndex)
        {
            Show();
            SkillBaseData skillData = heroData.skills[heroData.cfgData.DefaultSkill[skillIndex]];
            ui.lv.text = APIUIHeroInfo.GetStrSkillLevel(skillData.lv, skillData.isMaxLv);
            SetImageSprite(ui.icon, skillData.cfgData.Icon_fullPath);
            ui.lockRoot.SetActive(!skillData.isUnlock);
            ui.imageSelectType.SetInt(heroData.cfgData.HeroElementType);
            ui.imageType.SetInt(heroData.cfgData.HeroElementType);
            SetSelected(false);
        }

        public void SetSelected(bool selected)
        {
            //ui.lv.indexSwitchColor = selected ? 1 : 0;
            ui.select.SetActive(selected);
        }
        #endregion methonds
    }
}
